﻿namespace Sidvall.WorkItemManager.Data.Entity.Entities
{
    public partial class WorkItemSensor : global::Sidvall.Data.DataRowBase, global::Sidvall.WorkItemManager.Data.IWorkItemSensor
    {
        #region Public Members

        #region Description

        private string _Description;
        public string Description
        { 
            get
            {
                return _Description;
            }
            set
            {
                _Description = value;
            }
        }

        #endregion
        #region Name

        private string _Name;
        public string Name
        { 
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        #endregion
        #region Value

        private string _Value;
        public string Value
        { 
            get
            {
                return _Value;
            }
            set
            {
                _Value = value;
            }
        }

        #endregion
        #region ValueTimestamp

        private System.Nullable<System.DateTime> _ValueTimestamp;
        public System.Nullable<System.DateTime> ValueTimestamp
        { 
            get
            {
                return _ValueTimestamp;
            }
            set
            {
                _ValueTimestamp = Sidvall.Business.ValidationManager.GetValidUniversalDateTime(value, System.DateTimeKind.Utc);
            }
        }

        #endregion
        #region WorkItemId

        private long _WorkItemId;
        public long WorkItemId
        { 
            get
            {
                return _WorkItemId;
            }
            set
            {
                _WorkItemId = value;
            }
        }

        #endregion
        #region WorkItemSensorId

        private long _WorkItemSensorId;
        public long WorkItemSensorId
        { 
            get
            {
                return _WorkItemSensorId;
            }
            set
            {
                _WorkItemSensorId = value;
            }
        }

        #endregion
        
        public virtual Sidvall.WorkItemManager.Data.Entity.Entities.WorkItem WorkItem { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.WorkItemManager.Data.Entity.Entities.WorkItemSensorLog> WorkItemSensorLog { get; set; }
        
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.Data.Entity.SystemContext.Current.EntityFacade.WorkItemSensorManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.Data.Entity.SystemContext.Current.EntityFacade.WorkItemSensorManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region IWorkItemSensor Members

        string global::Sidvall.WorkItemManager.Data.IWorkItemSensor.Description
        {
            get
            {
                return this._Description;
            }
            set
            {
                this.Description = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItemSensor.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this.Name = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWorkItemSensor.Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                this.Value = value;
            }
        }
        System.Nullable<System.DateTime> global::Sidvall.WorkItemManager.Data.IWorkItemSensor.ValueTimestamp
        {
            get
            {
                return this._ValueTimestamp;
            }
            set
            {
                this.ValueTimestamp = value;
            }
        }
        long global::Sidvall.WorkItemManager.Data.IWorkItemSensor.WorkItemId
        {
            get
            {
                return this._WorkItemId;
            }
            set
            {
                this.WorkItemId = value;
            }
        }
        System.Nullable<long> global::Sidvall.WorkItemManager.Data.IWorkItemSensor.WorkItemSensorId
        {
            get
            {
                return this._WorkItemSensorId;
            }
            set
            {
                if (value != null)
                    this.WorkItemSensorId = value.Value;
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        IWorkItem global::Sidvall.WorkItemManager.Data.IWorkItemSensor.WorkItem
        {
            get
            {
                return this.WorkItem;
            }
            set
            {
                this.WorkItem = value as WorkItem;
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IWorkItemSensorLog> global::Sidvall.WorkItemManager.Data.IWorkItemSensor.WorkItemSensorLogs
        {
            get
            {
                return this.WorkItemSensorLog;
            }
        }
        void global::Sidvall.WorkItemManager.Data.IWorkItemSensor.SetWorkItemSensorLogs(Sidvall.Data.IDataRowProvider<global::Sidvall.WorkItemManager.Data.IWorkItemSensorLog> items)
        {
            this.WorkItemSensorLog = items as WorkItemSensorLogCollection;
        }

        #endregion

        #endregion
        #region Constructors

        public WorkItemSensor() : this(false, null, null)
        {
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public WorkItemSensor(bool initializeChildren, Sidvall.Data.IDataRowContextProvider context, Sidvall.Data.DataRowState? dataRowState)
        {
            if ((context != null) || (dataRowState != null))
                SetDataRowContext(context, dataRowState);
            if (initializeChildren)
            {
                this.WorkItemSensorLog = new System.Collections.Generic.List<WorkItemSensorLog>();
            }
        }

        #endregion
    }
}